#ifndef CLIENTREQUESTS_H_
#define CLIENTREQUESTS_H_

#include <s32mem.h>
#include "scatu/Utils.h"

namespace scatu {

class RClientRequestCommon
    {
public:
    
    // Provide a close function even though nothing needs to be closed on client side
    void Close() {}
    
protected:
    RClientRequestCommon(TServerFunction aFunction)
      : iFunction(aFunction) {}

    HBufC8 * ReadReturnValueLC(RSessionBase & aSession, TInt size)
        {
        HBufC8 * returnBuf = HBufC8::NewLC(size);
        TPtr8 returnPtr(returnBuf->Des());
        User::LeaveIfError(aSession.SendReceive(RET_FUNC(iFunction), TIpcArgs(&returnPtr)));
        return returnBuf;
        }
    
private:
    TServerFunction iFunction;
    
    };

} // namespace scatu

#endif /* CLIENTREQUESTS_H_ */
